<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
    <title>
        js调用java
    </title>
</head>

<body>
<input type="button" id="test" onclick="getContacts('5fsdfdsfsdfsdfs')" value="获取联系人" />
</body>
<script type="text/javascript">

function connectWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge)
            } else {
                document.addEventListener(
                    'WebViewJavascriptBridgeReady'
                    , function() {
                        callback(WebViewJavascriptBridge)
                    },
                    false
                );
            }
        }

function gotoApp(action) {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'gotoApp'
                , action
                , function(responseData) {

                }
            );
        }


    function getContacts(accessToken) {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'getContacts'
                , accessToken
                , function(responseData) {

                }
            );
        }



connectWebViewJavascriptBridge(function(bridge) {

 bridge.registerHandler("setContact", function(data, responseCallback) {
                alert(data);

            });
});

</script>

</html>